home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Communications / General / LineShare Folder / Put Onto Productions Disks / LineShare Scripts / Generic ARA&Data < prev    next >
Text File  |  1994-02-18  |  6KB  |  265 lines

  1. !$ Version 2.1
  2. !$ Requires: any modem
  3.  
  4. !$ Supports: ARA and a generic comm. software (QuickMail, BBS, etc) in the server mode.
  5.  
  6. !$ Use:  ARA/LineShare for ARA.
  7.  
  8. !$ Read:  your modem manual to modify the "AT" strings.
  9.  
  10. !$ See:   the Generic Scripts Guide for details.
  11.  
  12. ^2 Speaker On:        = Enum("Never" = "0" ,  "When Connecting" = "1", "Always"="2") "1"
  13. ^3 Speaker Volume:    = Enum("Low"="1","Medium"="2","High"="3") "2"
  14. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  15. ^5 Adjust Port Speed: = Bool("Yes"="1","No"="0") "0"
  16. ^6 AT for Receive:    = Text ""
  17. ^7 AT for ARA calls:  = Text ""
  18. ^8 Max Port Speed:    = Enum("2400","9600","19200","38400") "9600"
  19.  
  20. ! ------------------------------------------
  21. ! Resetting the modem:
  22. ! ------------------------------------------
  23. @Hangup
  24.   SetTries 2
  25.   Flush
  26.   HsReset 0,0,17,19,0,0
  27. !
  28. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  29. ! to enter the command mode
  30. !
  31. @Label 1
  32.   matchclr
  33.   matchstr 1 2 "OK\r\n"
  34.   write "ATH0&F\r"
  35.   matchread 20
  36.   ChrDelay 1
  37.   Write "+++"
  38.   ChrDelay 0
  39.   DtrClear
  40.   pause 10
  41.   DtrSet
  42. !
  43.   DecTries
  44.   IfTries 0 1
  45. !
  46. ! OSErr -6019 "Modem error - the modem is not responding"
  47. !
  48.   exit -6019
  49. @Label 2
  50.   exit 0
  51. ! ------------------------------------------
  52. !    Receiving incoming calls
  53. ! ------------------------------------------
  54. @ANSWER
  55.   SetVar A ""
  56.   IfStr A 50 "^6^7"
  57. @Label 10
  58.   SerReset Val("^8"),0,8,1
  59.   Jsr 80
  60. !
  61. ! Set the common options
  62.   Jsr 70
  63. !
  64. ! Set the communication options:
  65. ! • ^6 for receive mode (disable MNP), <DCE Speed>/ARQ message, hw flow control
  66.   Write "AT^6\r"
  67.   Jsr 100
  68. !
  69. ! Tell the modem to determine the type of the incoming call
  70. ! Fetch the tube after ^4 rings
  71. !
  72.   Write "ATS0=^4\r"
  73.   Jsr 100
  74.   Note "Waiting for ARA/Data calls…"
  75. !
  76. ! Everything is ready - let's sit and wait for a call
  77. ! We'll wait for 2 minutes, then reinitiate the modem
  78. !
  79. @Label 12
  80.   MatchClr
  81.   matchstr 1 13 "RING\r\n"
  82.   matchstr 2 21 "\r\nCONNECT ^$/"
  83.   matchstr 3 15 "\r\nCONNECT ^$\r\n"
  84.   matchstr 10 10 "\r\nNO "
  85.   matchstr 11 10 "\r\nBUSY"
  86.   Matchread 1200
  87.   Jump 10
  88. @Label 13
  89.   Note "Ring…"
  90.   Jump 12
  91. !
  92. ! Data connection has been established (we read "CONNECT XXX\r\n")
  93. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  94. ! if it was an incoming call, put the "RING" before the "CONNECT"
  95. !
  96. @Label 15
  97.   SetVar A "^$"
  98.   Note "Non-V.42 Call at ^A bps. Waiting for an ARA frame."
  99.   MatchClr
  100.   MatchStr 1 20 "\r"
  101.   MatchStr 2 30 "\08\01\03\14\04\03\00\08\250\16\03"
  102.   MatchRead 40
  103.  
  104. @Label 20
  105.   Note "Non-ARA call"
  106.   Jump 24
  107. !
  108. ! V.42 call detected
  109. !
  110. @Label 21
  111.   SetVar A "^$"
  112.   Note "V.42 Call at ^A bps"
  113.   MatchClr
  114.   MatchStr 1 24 "\r\n"
  115.   MatchRead 5
  116. @Label 24
  117.   QueueInput "\r\nRING\r\n\r\nCONNECT ^A\r\n"
  118. @Label 25
  119.   Attach "Data" (DTR,Escape,TimeLimit=0)
  120.  
  121. !
  122. ! The ARA (MNP 4) frame detected
  123. !
  124. @Label 30
  125.   Note "ARA call at ^A bps."
  126.   Flush
  127.   QueueInput " ^A\r\n"
  128. @Label 31
  129.   ifStr 5 32 "1"
  130.   QueueInput "\r\nCARRIER "
  131.   Jump 35
  132. @Label 32
  133.   QueueInput "\r\nCONNECT "
  134. @Label 35
  135.   ifOriginate 36
  136.   QueueInput "\r\nRING\r\n"
  137. @Label 36
  138.   Attach "ARA" (DTR,Escape,TimeLimit=0)
  139.  
  140. @Label 50
  141.   Note "Suspended"
  142.   Say "Press the Option button to enter the AT-strings for your modem!"
  143.   Pause 1200
  144.   Jump 50
  145. ! ------------------------------------------
  146. ! Originating a call through the "ARA" subport
  147. ! ------------------------------------------
  148. @ORIGINATE "ARA"
  149.   SerReset Val("^8"),0,8,1
  150.   Jsr 80
  151. !
  152. ! Set the common options
  153. !
  154.   Jsr 70
  155. !
  156. ! Set the Data mode:
  157. ! • ^7  For ARA calls
  158. ! • S7:  time-out (90 sec) for long-distance call (if you use them)
  159. !
  160.   Write "AT^7S7=90\r"
  161.   Jsr 100
  162. !
  163. ! Prepare to receive all error result codes
  164. !
  165.   Jsr 90
  166.   MatchStr 1 31 "\r\nCONNECT"
  167.   MatchRead 900
  168.   Write "\r"
  169.   Exit -6019
  170.  
  171. ! ------------------------------------------
  172. ! Originating a call through the "Data" subport
  173. ! ------------------------------------------
  174. @ORIGINATE "Data"
  175.   SerReset Val("^8"),0,8,1
  176.   Jsr 80
  177.   Jsr 70
  178. !
  179. ! Now emit all commands that the application has sent to that port
  180. !
  181.   Jsr 60
  182.   SerReset *
  183.   Jsr 80
  184. !
  185. ! Prepare to receive all error result codes
  186. !
  187.   Flush
  188.   Jsr 90
  189.   MatchStr 1 48 "^$\r\nCONNECT"
  190.   MatchRead 900
  191.   Write "\r"
  192.   Exit -6019
  193. @Label 48
  194.   QueueInput "^$\r\nCONNECT"
  195.   Jump 25
  196.  
  197. !
  198. ! This section emits all modem commands sent from the client application
  199. ! For each set of commands the "OK" answer is awaited
  200. !
  201. @Label 60
  202.   EmitStart
  203. @Label 61
  204.   EmitCommand 62
  205.   Jsr 100
  206.   Jump 61
  207. @Label 62
  208.   return
  209. !
  210. ! This section initiates the modem before ANSWER and ORIGINATEs:
  211. ! dialtone detect + connect at the highest rate + speaker control +
  212. ! hang up on Dtr drop + DCD valid
  213. ! Verbal responses mode, no echo
  214. ! Disable extended codes
  215. !
  216. @Label 70
  217.   Write "ATX4M^2L^3&D2&C1V1E0\r"
  218.   Jsr 100
  219.   return 
  220. !
  221. ! This section syncronize the modem after the serial port speed switching
  222. !
  223. @Label 80
  224.   ChrDelay 1
  225.   Write "AT\r"
  226.   ChrDelay 0
  227.   Jsr 100
  228.   return
  229. !
  230. ! Prepare to receive error result codes
  231. !
  232. @Label 90
  233.   MatchClr
  234.   MatchStr 2 91 "NO DIALTONE\r\n"
  235.   MatchStr 3 92 "BUSY\r\n"
  236.   MatchStr 4 93 "NO CARRIER\r\n"
  237.   MatchStr 5 94 "NO ANSWER\r\n"
  238.   Write "ATD^1\r"
  239.   HsReset *
  240.   return
  241.  
  242. @Label 91
  243.   exit -6020
  244. @Label 92
  245.   exit -6022
  246. @Label 93
  247.   exit -6021
  248. @Label 94
  249.   exit -6023
  250. !
  251. ! Processing the AT command:
  252. ! OK -> proceed
  253. ! ERROR or TimeOut ->exit -6019
  254. ! It can be called AFTER the "Write" command, since LineShare buffers input
  255. !
  256. @Label 100
  257.   MatchClr
  258.   MatchStr 1 102 "\r\nOK\r\n"
  259.   MatchStr 2 101 "\r\nERROR\r\n"
  260.   MatchRead 20
  261. @Label 101
  262.   Exit -6019
  263. @Label 102
  264.   return
  265.